<?php
namespace app\member\controller;

use think\Controller;
use think\Model;
use think\View;
use think\Request;
class Register extends Controller
{
	protected $model=null;
	
	public function _initialize(){
		parent::_initialize();
		$this->model=model('User');	
	}
	
	public function index(){
		$view=new View();
		return $view->fetch();
	}
	public function regDo(){
		//p($_POST);
		
		
		if(!request()->isPost()){
			$this->error('非法请求');
		}
		//dump(Request::instance()->post());die;
		$data=[
			'nickname'=>input('post.nickname'),
			'password'=>input('post.password'),
			'marriage'=>input('post.marriage'),
			'sex'=>input('post.sex'),
			'birthday'=>input('post.year').input('post.month').input('post.day'),
			'province'=>input('post.province'),
			'city'=>input('post.city'),
			'height'=>input('post.height'),
			'weight'=>input('post.weight'),
			'income'=>input('post.income'),
			'mobile'=>input('post.mobile'),
			'note1'=>input('post.note1'),
			'note2'=>input('post.note2'),
			'note3'=>input('post.note3'),
			'education'=>input('post.education')
		];
		$user=$this->model;
		if($user->allowField(true)->insert($data)){
			$this->success('注册成功',url('Index/index'));
		}else{
			$this->error('注册失败');
		}
	}
}